<?php defined('SYSPATH') OR die('No direct access allowed.'); ?>

	<script type="text/javascript">
	 	dojo.require("dijit.Editor");
		dojo.require("dijit.form.ValidationTextBox");
		dojo.require("dijit.form.DateTextBox");
		dojo.require("dojox.validate.regexp");
		dojo.require("dojo.parser");
	</script>
	
	<script type="text/javascript">
		$(document).ready(function() {
			$("input[name='btnCancle']").click(function() {
				var uri = ISS.lang.getBasePath()+'index.php/admin/album';
				window.location = uri;
			});
		}); 
	</script>
	
	<?php 	
	if (!empty($form['cover_picture'])) {
		echo html::Stylesheet(
			array
			(
				'media/css/album_picture_block.css',
			),
			array
			(
				'screen',
			)
		);	
	}
	else {
		echo html::Stylesheet(
			array
			(
				'media/css/album_block.css',
			),
			array
			(
				'screen',
			)
		);	
	}
	?>
	
	<div id="albumContainer">
		<?php print form::open_multipart('admin/album/save');?>
	    
		    <div id="albumBlock">
		        <div id="albumBlockTop">
		          <h3><?php echo ($mode=='add') ? 'เพิ่มอัลบัม' : 'แก้ไขอัลบัม'; ?></h3>
		          	<?php 
		          		$array = array('mode' => $mode);
						print form::hidden($array);
						if ($mode=='edit') {
		          			$array = array('id' => $form['id']);
							print form::hidden($array);
						}
						?>
		          <p><?php echo (empty($status) ? 'กรุณาระบุข้อมูลให้ครบถ้วน' : html::specialchars($status)); ?></p>
		        </div>
		        <div id="albumBlockBody">
					<table>
						<tr>
							<td>ชื่อ::</td>
							<td>
								<input id="txtTitle" type="text" name="txtTitle"
									value="<?php echo html::specialchars($form['title']); ?>"
								    style="width: 210px;" 
								    dojoType="dijit.form.ValidationTextBox"
								    trim="true"
								    required="true"
								    invalidMessage="กรุณาระบุชื่ออัลบัม" />
								<div id='errTitle' class='albumBlockError'>
									<?php echo (empty ($errors['txtTitle'])) ? '' : $errors['txtTitle']; ?>
								</div>
							</td>
						</tr>
						<tr>
						<td>วันที่จัดจำหน่าย::</td>
						<td>
							<input id="txtReleasedDate" type="text" name="txtReleasedDate" value="<?php echo html::specialchars($form['released_date']) ?>"
								dojoType="dijit.form.DateTextBox"
							/>
							<div id='errReleasedDate' class='albumBlockError'>
									<?php echo (empty ($errors['txtReleasedDate'])) ? '' : $errors['txtReleasedDate']; ?>
								</div>
						</td>
						</tr>
						<tr>
							<td>รูปปกอัลบัม::</td>
							<td>
								<?php
									if (!empty($form['cover_picture'])) {
										echo '<img id=imgCoverPicture  alt="'. html::specialchars($form['title']) .'" src="'. url::base() . html::specialchars($form['cover_picture']) .'" />';
										echo '<br/>';
									} 
									$attributes = array('name' => 'txtCoverPicture');
									echo form::upload($attributes, '');	
								?>
								<div id='errAlbumsPicture' class='albumBlockError'>
									<?php echo (empty ($errors['txtCoverPicture'])) ? '' : $errors['txtCoverPicture']; ?>
								</div>
							</td>
						</tr>
					</table>
		        </div>

		     </div>
		     <div id="albumBlockBot">
		     	<?php 
		     		print form::submit('btnSave', 'บันทึก'); 
		     	?>
		     	<input type="button" id="btnCancle" name="btnCancle" value="ยกเลิก" />
		     </div>
		 <?php print form::close(); ?>
	 </div>
